import request from '@/util/request';

/**
 * 获取职位列表
 * @param {Object} params 
 * @param {integer} params.page 
 * @param {integer} params.size 
 * @param {string} [params.content] 
 * @returns {Promise<Object>} 
 */
export const getPositions = async (params) => {
  return request.get('/manager/position/getPositions', {
    params: params
  })
}
/**
 * 获取指定岗位信息
 * @param {Object} params - 请求参数对象
 * @param {integer} params.positionId - 管理员用户 ID
 * @returns {Promise<Object>} - 返回结果
 */
export const getPositionMessage = (params) => {
  // console.log('请求参数为',params)
  return request.get('/manager/position/getPositionMessage', {
    params: params
  })
}

//获取待审核职位信息
export const getPublishPositionLists = async () => {
  return request.get('/manager/position/getPublishPositionLists')
};
//获取待变更职位信息
export const getUpdatedPositionLists = async () => {
  return request.get('/manager/position/getUpdatedPositionLists')
};



/**
 * 岗位审核通过
 * @param {string} code - 发布岗位的唯一标识
 * @returns {Promise<Object>} - 返回审核结果
 */
export const verifyPublishPosition = (code) => {
  return request.post('/manager/position/verifyPublishPosition', null, { params: { code } });
};
/**
 * 岗位变更通过
 * @param {number} positionId - 发布岗位的唯一标识
 * @returns {Promise<Object>} - 返回审核结果
 */
export const VerifyChangePosition = (positionId) => {
  const params = {
    positionId: Number(positionId),
  }
  // console.log('请求的参数', params, typeof params.positionId);
  return request.post('/manager/position/VerifyChangePosition', null, { params: { positionId } });
};

/**
 * 职位审核不通过
 * @param {string} code - 发布岗位的唯一标识
 * @param {string} failMessage - 错误反馈信息
 * @returns {Promise<Object>} - 返回审核结果
 */
export const verifyPublishPositionFailed = (code, failMessage) => {
  return request.post('/manager/position/verifyPublishPositionFailed', null, { params: { code, failMessage } });
};

/**
 * 职位变更不通过
 * @param {number} positionId - 发布岗位的唯一标识
 * @param {string} failedMessage - 错误反馈信息
 * @returns {Promise<Object>} - 返回审核结果
 */
export const VerifyChangePositionFailed = (positionId, failedMessage) => {
  const params = {
    positionId: Number(positionId),
    failedMessage: failedMessage.trim() || '审核拒绝'
  }
  return request.post('/manager/position/VerifyChangePositionFailed', null, { params: params });
}; 
